import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("wx")
class Wx extends BaseService {
	// 获取所有模板列表
	privateTpls(params) {
		return this.$get('/getPrivateTemplates', { params })
	}
	// 发送模板列表
	sendTplList(params) {
		return this.$get('/sendTemplateList', { params })
	}
	// 定时发送模板（修改）
	sendTpl(params) {
		return this.$post('/sendTemplate', params)
	}
	//上传素材到公众号（一个公众号多个素材）
    syncMaterial(params) {
		return this.$post('/syncMaterial', params)
	}

	// 列表
	page({ size, ...args }) {
		let params = {
			pageSize: size,
			...args
		};
		return this.$get("/pool/lists", { params }).then(res => {
			console.info("res.lists", res.list)
			return {
				list: res.list,
				pagination: {
					page: 1,
					size,
					total: res.count
				}
			}
			// let list = (res || []).reduce((prev, { children, ...curr }) => {
			// 	return [...prev, ...(children || []).map(v => ({ ...v, parent: curr }))];
			// }, []);
			// return {
			// 	list,
			// 	pagination: {
			// 		...params,
			// 		size,
			// 		total: list.length
			// 	}
			// };
		});
	}

	lists(params) {
		return this.$get("/pool/lists", { params })
	}

	add(params) {
		// const customer_links = params.customer_links;
		// params.customer_links = customer_links ? customer_links.split(";") : '';
		return this.$post('/pool/add', params)
	}

	edit(params) {
		// const customer_links = params.customer_links;
		// params.customer_links = customer_links ? customer_links.split(";") : '';
		return this.$post('/pool/edit', params)
	}

	bindPool(params) {
		return this.$post('/bindPool', params)
	}

	userList(params) {
		return this.$get("/pool/userList", { params })
	}

	userTurnOff(params) {
		return this.$post('/pool/userTurnOff', params)
	}

	userTurnOn(params) {
		return this.$post('/pool/userTurnOn', params)
	}

	remove(params) {
		return this.$post('/pool/remove', params)
	}
	userAdd(params) {
		return this.$post('/pool/userAdd', params)
	}
  updateMax(params) {
		return this.$post('/pool/updateMax', params)
	}
}
export default Wx
